//
// Created by guanyicheng on 2021/11/8.
//

#include <iostream>
#include <vector>

using namespace std;

int how(int n) {
    if (n < 2) {
        return 0;
    }
    if (n == 2) {
        return 1;
    }
    int t = n / 3;
    return t + how(t + n % 3);
}

int main() {
    auto res = vector<int>();
    while (true) {
        int in;
        cin >> in;
        if (in == 0) {
            break;
        }
        res.emplace_back(how(in));
    }
    for(auto &i: res) {
        cout << i << endl;
    }
}